<?php

namespace app\webapi\controller;

use app\webapi\common\BaseController;
use app\webapi\vms\service\AuxiliaryService;
use app\webapi\vms\validate\AuxiliaryValidate;
use library\OWException;
use think\App;
use think\facade\Request;

/**
 * @辅助控制器
 */
class AuxiliaryController extends BaseController
{
    /**
     * @var AuxiliaryValidate
     */
    protected $validate;

    /**
     * @var AuxiliaryService
     */
    protected $service;

    /**
     * @param App $app
     */
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->validate = new AuxiliaryValidate();
        $this->service = new AuxiliaryService();
    }

    /**
     * @desc 图片上传
     * @return \think\response\Json
     * @author zhaozhiwei
     * @time 2023/12/14-17:23
     */
    public function uploadImages(){
        $files=Request::file('file');
        if(empty($files)){
            throw new OWException('您还没有选择图片');
        }
        $res=$this->service->uploadImages($files);
        return $this->responseSuccess($res);
    }

    /**
     * @desc 获取平台列表
     * @return \think\response\Json
     * @author zhaozhiwei
     * @time 2023/12/14-17:38
     */
    public function getDistributionMediaList(){
        $params = $this->validate->goCheck('getDistributionMediaList');
        $res = $this->service->getDistributionMediaList($params);
        return $this->responseSuccess($res);
    }
}